package basics.proxy.dynamicProxy;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

/**
 * @author jiangwz
 * @create 2021/3/10.
 */
public class DebugInvocationHandler implements InvocationHandler {

    private Object target;

    public DebugInvocationHandler(Object target) {
        this.target = target;
    }

    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        System.out.println("proxy->before");
        Object invoke = method.invoke(target, args);
        System.out.println("invoke="+ invoke);
        System.out.println("proxy->after");
        return invoke;
    }
}
